/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package shellCommands;

import Sessions.EcomAdminRemote;
import Sessions.EcomCustomersRemote;
import java.util.StringTokenizer;

/**
 *
 * @author SOGOBA
 */
public class LanguageCommand implements InterShell{
  private ContextCommande cxtCmd;

    public LanguageCommand (ContextCommande ContextCommand){
          cxtCmd =  ContextCommand;
    }

    @Override
    public Commands getName() {
        return Commands.language;
    }

    @Override
    public String getShortDescription() {
        return "output en|fr|es|it to change the output  languague";
    }

    @Override
    public void execute(String cmd,EcomAdminRemote ecomAdmin,EcomCustomersRemote ecomCust) {
        StringTokenizer st = new StringTokenizer(cmd, " ");
        // Ignore the command name.
        st.nextToken();
        // There should be at least one string.
        if (st.countTokens()==1){
           String str=st.nextToken().trim();
            switch (str) {
                case "en":
                    cxtCmd.setVar("language", "en");
                    break;
                case "fr":
                    cxtCmd.setVar("language", "fr");
                    break;
            }
             System.out.println("the language is correctly change to "+str);
            }
        else {
            System.out.println("Incorrect number of arguments");
        }
    }
}
